package com.kgc.pageItem.controller;

import com.kgc.entity.TbItem;
import com.kgc.entity.TbItemDesc;
import com.kgc.pageItem.entity.Item;
import com.kgc.service.ItemDescService;
import com.kgc.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PageDetailController {
    @Autowired
    private ItemService itemService;

    @Autowired
    private ItemDescService itemDescService;
    @RequestMapping(value = "item/{itemId}")
    public String pageItem(@PathVariable("itemId")Long itemId, Model model){
        TbItem tbitem=itemService.findById(itemId);
        Item item=new Item(tbitem);
        TbItemDesc itemDesc=itemDescService.findById(itemId);
        //3.传给前台展示
        model.addAttribute("item",item);
        model.addAttribute("itemDesc",itemDesc);
        return "item";
      /*  return "redirect:http://localhost:8888/"+itemId+".html";*/
    }
}
